-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Move appropriate methods out of Real and into new traits #6110
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
…rigonometric, Exponential and Hyperbolic traits
…dd' and 'is_even'
I thought Hyperbolic and Exponential were going to merged? (Or did I miss something on IRC?) |
@huonw Ack sorry, for some reason I thought we'd agreed to keep them separate. Re-reading the exchange I misinterpreted. I'll merge them now. Sorry, wasn't meaning to sneak anything by you. What's your nick on IRC btw? |
The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's simpler to group them the Exponential trait. In the future these would have default implementations.
Merging sinh, cosh and tanh with Exponential seems like a really bad idea imho. In addition to the reasons given in #4819 it would also prevent (possibly sanely) matrix types from implementing it. |
After discussions on IRC and rust-lang#4819, we have decided to revert this change. This is due to the traits expressing different ideas and because hyperbolic functions are not trivially implementable from exponential functions for floating-point types.
As discussed on issue #4819, I have created four new traits: `Algebraic`, `Trigonometric`, `Exponential` and `Hyperbolic`, and moved the appropriate methods into them from `Real`. ~~~rust pub trait Algebraic { fn pow(&self, n: Self) -> Self; fn sqrt(&self) -> Self; fn rsqrt(&self) -> Self; fn cbrt(&self) -> Self; fn hypot(&self, other: Self) -> Self; } pub trait Trigonometric { fn sin(&self) -> Self; fn cos(&self) -> Self; fn tan(&self) -> Self; fn asin(&self) -> Self; fn acos(&self) -> Self; fn atan(&self) -> Self; fn atan2(&self, other: Self) -> Self; } pub trait Exponential { fn exp(&self) -> Self; fn exp2(&self) -> Self; fn expm1(&self) -> Self; fn log(&self) -> Self; fn log2(&self) -> Self; fn log10(&self) -> Self; } pub trait Hyperbolic: Exponential { fn sinh(&self) -> Self; fn cosh(&self) -> Self; fn tanh(&self) -> Self; } ~~~ There was some discussion over whether we should shorten the names, for example `Trig` and `Exp`. No abbreviations have been agreed on yet, but this could be considered in the future. Additionally, `Integer::divisible_by` has been renamed to `Integer::is_multiple_of`.
…=llogiq "Respect" enums in `interior_mutable_const` fixes rust-lang#3962 fixes rust-lang#3825 Hello, It might not be a good idea to submit another relatively large PR while I have an opened PR; but, I've finished this anyway. This may be able to wait for months. Note: the code uses the MIR interpreter, which the author of rust-lang#3962 thought unlikely to be a solution. This might be over-engineering; but, I think it's important to be able to work with the 'http' crate (rust-lang#3825). (And, I don't want to write a MIR visitor) --- changelog: fix a false positive in two `interior_mutable_const` lints where a constant with enums gets linted even if it uses a clearly unfrozen variant
…ust-lang#14078) Remove "Known problems" section for `borrow_interior_mutable_const` since issue were fixed some time ago - rust-lang#6110, rust-lang#5812 changelog: none
As discussed on issue #4819, I have created four new traits:
Algebraic
,Trigonometric
,Exponential
andHyperbolic
, and moved the appropriate methods into them fromReal
.There was some discussion over whether we should shorten the names, for example
Trig
andExp
. No abbreviations have been agreed on yet, but this could be considered in the future.Additionally,
Integer::divisible_by
has been renamed toInteger::is_multiple_of
.